
import java.io.IOException;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.GameCanvas;

/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
/**
 *
 * @author student
 */
public class Splash extends GameCanvas implements Runnable {

    boolean flicker = true;

    public Splash() {
        super(true);
        setFullScreenMode(true);
        new Thread(new Runnable() {

            public void run() {
                while (true) {
                    if (flicker == true) {
                        flicker = false;
                    } else {
                        flicker = true;
                    }
                    repaint();
                    int ks = getKeyStates();
                    if ((ks) != 0) {
                        Manager.setCurrent(Manager.F_Menu);
                    }
//                        else if ((ks & LEFT_PRESSED) != 0) {
//                        Manager.setCurrent(Manager.F_Menu);
//                    } else if ((ks & UP_PRESSED) != 0) {
//                        Manager.setCurrent(Manager.F_Menu);
//                    } else if ((ks & DOWN_PRESSED) != 0) {
//                        Manager.setCurrent(Manager.F_Menu);
//                    }
                    try {
                        Thread.sleep(400);
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
                    }
                }
            }
        }).start();
    }

    public void paint(Graphics g) {
        int w = getWidth();
        int h = getHeight();
        g.setColor(0xffffff);
        g.fillRect(0, 0, w, h);
        Image img = null;
        try {
            img = Image.createImage("/Splash64.png");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        g.drawImage(img, w / 2, h / 2, Graphics.VCENTER | Graphics.HCENTER);
        try {
            img = Image.createImage("/Name.png");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        g.drawImage(img, w / 2, 100, Graphics.VCENTER | Graphics.HCENTER);
        if (flicker == true) {
            try {
                img = Image.createImage("/press.png");
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            g.drawImage(img, w / 2, 250, Graphics.VCENTER | Graphics.HCENTER);
        }
    }

    public void run() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
